﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UI.ParentForm;
using Components;
using UI.Lib;

namespace UI.BaseResource
{
    public partial class FrmPsn1a00 : BaseMain
    {
        FrmPsn1a00Edit edit = null;

        public FrmPsn1a00(string modulecode, string action)
            : base(modulecode, action)
        {
            InitializeComponent();
        }

        protected override void OnAddClick(ToolStripButton btn)
        {
            edit = new FrmPsn1a00Edit("A", GetTitleStyle(this.Text, btn.Text), "");
            edit.ShowDialog();
            if (edit.IsReload) base.BindGrid();
        }

        protected override void OnEditClick(ToolStripButton btn, DataGridViewRow row)
        {
            OpenEdit("M", btn.Text, Validation.ToString(row.Cells["listid"].Value));
        }

        protected override void OnDeleteClick(ToolStripButton btn, DataGridViewRow row)
        {
            OpenEdit("D", btn.Text, Validation.ToString(row.Cells["listid"].Value));
        }

        protected override void OnViewClick(ToolStripButton btn, DataGridViewRow row)
        {
            OpenEdit("V", btn.Text, Validation.ToString(row.Cells["listid"].Value));
        }

        private void OpenEdit(string action, string btnText, string code)
        {
            edit = new FrmPsn1a00Edit(action, GetTitleStyle(this.Text, btnText), code);
            edit.ShowDialog();
            if (edit.IsReload) base.BindGrid();
        }

        protected override void UpdatePager(UI.Common.Pager pager)
        {
            pager.FilterAppName = "usercode"; //服务器自动为usercode添加公司约束
        }
    }
}
